<!DOCTYPE html>

<html>
    <?php

         require_once("Config.php");
          $template = new Config;
          $baseDir = "/var/www/newGoogleRep/eventsmanager/server/view/";
          $root =& $template->parseConfig($baseDir.'Theme.xml', 'XML');
          if (PEAR::isError($root)) {
          die('Error while reading configuration: ' . $root->getMessage());
           }

          $settings = $root->toArray();

          $variable=$settings['root']['template']['templateName'];
          echo '<head>';
              echo  "<link type=\"text/css\" href=\"css/$variable/jquery-ui-1.8.12.custom.css\" rel=\"stylesheet\" />";
          echo '<head>';

    ?>

    <body>
        <?php

 require_once("Config.php");
 $template = new Config;
 $baseDir = "/var/www/newGoogleRep/eventsmanager/server/view/";
 $root =& $template->parseConfig($baseDir.'Theme.xml', 'XML');
 if (PEAR::isError($root)) {
    die('Error while reading configuration: ' . $root->getMessage());
 }

 $settings = $root->toArray();
 $lastRotated = $settings['root']['template']['lastRotateDate'];
 $lastRotatedFolder =  $settings['root']['template']['lastRotateFolder'];
 $today = date('Y-m-d');


 ?>
 <form action ="" method ="POST">
     <tr>
         <td>
            Template
         </tr>
     <tr>
     <tr>
         <td>
<select name="template">
<option value="1">Black-Tie</option>
<option value="2">Blitzer</option>
<option value="3">Cupertino</option>
<option value="4">Dark-Hive</option>
<option value="5">Dot-Luv</option>
<option value="6">Eggplant</option>
<option value="7">Excite-bike</option>
<option value="8">Flick</option>
<option value="9">Hot-sneaks</option>
<option value="10">Humanity</option>
<option value="11">Le-frog</option>
<option value="12">Mint-Choc</option>
<option value="13">Overcast</option>
<option value="14">Pepper-grinder</option>
<option value="15">Redmond</option>
<option value="16">Smoothness</option>
<option value="17">South-Street</option>
<option value="18">Start</option>
<option value="19">Sunny</option>
<option value="20">Swanky-Purse</option>
<option value="21">Trantastic</option>
<option value="22">UI-Darkness</option>
<option value="23">UI-Lightness</option>
<option value="24">Vader</option>
</select>
         <td>
     </tr>
     <tr>
         <td>
         <input type="Submit" value ="Save Changes">
         </td>
     </tr>
 </form>
 </body>
 </html>

 <html>
 <body>
    <?php



   switch ($_POST['template']) {
        case 1:
           $settings['root']['template']['templateName'] = "black-tie";
           break;
        case 2:
           $settings['root']['template']['templateName'] = "blitzer";
           break;
        case 3:
           $settings['root']['template']['templateName'] = "cupertino";
           break;
        case 4:
           $settings['root']['template']['templateName'] = "dark-hive";
           break;
        case 5:
           $settings['root']['template']['templateName'] = "dot-luv";
           break;
        case 6:
           $settings['root']['template']['templateName'] = "eggplant";
           break;
        case 7:
           $settings['root']['template']['templateName'] = "excite-bike";
           break;
        case 8:
           $settings['root']['template']['templateName'] = "flick";
           break;
        case 9:
           $settings['root']['template']['templateName'] = "hot-sneaks";
           break;
        case 10:
           $settings['root']['template']['templateName'] = "humanity";
           break;
        case 11:
           $settings['root']['template']['templateName'] = "le-frog";
           break;
        case 12:
           $settings['root']['template']['templateName'] = "mint-choc";
           break;
        case 13:
           $settings['root']['template']['templateName'] = "overcast";
           break;
        case 14:
           $settings['root']['template']['templateName'] = "pepper-grinder";
           break;
        case 15:
           $settings['root']['template']['templateName'] = "redmond";
           break;
        case 16:
           $settings['root']['template']['templateName'] = "smoothness";
           break;
        case 17:
           $settings['root']['template']['templateName'] = "south-street";
           break;
        case 18:
           $settings['root']['template']['templateName'] = "start";
           break;
        case 19:
           $settings['root']['template']['templateName'] = "sunny";
           break;
        case 20:
           $settings['root']['template']['templateName'] = "swanky-purse";
           break;
        case 21:
           $settings['root']['template']['templateName'] = "trantastic";
           break;
        case 22:
           $settings['root']['template']['templateName'] = "ui-darkness";
           break;
        case 23:
           $settings['root']['template']['templateName'] = "ui-lightness";
           break;
        case 24:
           $settings['root']['template']['templateName'] = "vader";
           break;

   }

   // echo "Last rotated: ".$lastRotated."\n";
    //$lastRotatedFolder = $settings['root']['conf']['lastRotateFolder'];
    //$settings['root']['conf']['lastRotateDate'] = 2011-05-13;
 //echo "Last rotated folder: ".$lastRotatedFolder."\n";
   //$settings['root']['conf']['lastRotateFolder'] = 40;

  // $settings = array(
   //    'lastRotateDate' => '2011-05-13',
      // 'lastRotateFolder' => '60',



  // );

   $template= new Config;
   //$root = &
   $template->parseconfig($settings['root']['template'], 'PHPArray');
   $options = array('name' => 'template');
   $template->writeConfig($basedir.'Theme.xml', 'xml', $options);


        ?>


    </body>
</html>
